package com.xhs.controller;

import com.xhs.dto.request.SendHttpParam;
import com.xhs.message.ReturnResult;
import com.xhs.service.TestService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @desc:
 * @projectName: http-forest-app
 * @author: xhs
 * @date: 2024-06-10 12:26
 * @version: JDK 1.8
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private TestService testService;

    /**
     * 发送Get请求 无参
     *
     * @return JSONObject
     */
    @PostMapping("/sendGet")
    public ReturnResult<Object> sendGet() {
        return testService.sendGet();
    }

    /**
     * 发送Get请求 有参
     *
     * @param param 入参
     * @return JSONObject
     */
    @PostMapping("/sendGetParam")
    public ReturnResult<Object> sendGetParam(@Valid @RequestBody SendHttpParam param) {
        return testService.sendGetParam(param);
    }

    /**
     * 发送Post请求 无参
     *
     * @return JSONObject
     */
    @PostMapping("/sendPost")
    public ReturnResult<Object> sendPost() {
        return testService.sendPost();
    }

    /**
     * 发送Post请求 有参 json格式
     *
     * @param param 入参
     * @return JSONObject
     */
    @PostMapping("/sendPostParam")
    public ReturnResult<Object> sendPostParam(@Valid @RequestBody SendHttpParam param) {
        return testService.sendPostParam(param);
    }
}
